﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoolERP_BLL;
using CoolERP_Entities;

namespace CoolERP_Web.User
{
    public partial class SCJHMX : BasePage
    {
        protected Guid JHID
        {
            get { return this.GetUrlParam("id") == null ? Guid.Empty : new Guid(this.GetUrlParam("id").ToString()); }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                BindData();
        }

        private void BindData()
        {
            using (SCJHBLL sBLL = new SCJHBLL())
            {
                SCJH entity = sBLL.GetEntity(t => t.ID == JHID);
                if (entity != null)
                {
                    liBH.Text = entity.BH;
                    liKSSJ.Text = entity.JHKSSJ.ToString("yyyy-MM-dd");
                    liWCSJ.Text = entity.JHWCSJ.ToString("yyyy-MM-dd");
                    liZT.Text = entity.JHZT == 1 ? "已完成" : "未完成";
                    
                }
            }
            //明细表
            using (SCJHMXBBLL xBLL = new SCJHMXBBLL())
            {
                int RecordCount = 0;
                List<XSHTMXBModel> mxbs = xBLL.GetSCJHMXB(JHID, "CPBH", null, 1, out RecordCount);
                GridView1.DataSource = mxbs;
                GridView1.DataBind();
                liMoney.Text = mxbs.Sum(t => t.SL * t.DJ).Value.ToString("C");
            }
        }
    }
}